﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LCA.Community.DAL.Model;
using Microsoft.Practices.Unity;
using LCA.Community.DAL.Interfaces;

namespace LCA.Community.Web.Models
{
    public class GroupViewModel : ISocialNetworkElement
    {
        public GroupViewModel(Group group)
        {
            Group = group;
        }

        #region Properties
        public Group Group { get; set; }

        public Object Element
        {
            get
            {
                return Group;
            }
        }

        public string Alias
        {
            get 
            {
                return Group.Alias;
            }
        }

        public List<PostViewModel> Posts
        {
            get
            {
                return PostViewModel.ConvertListPost(PostsRepository.GetPostByUser(Group.RowKey));
            }
        }

        public List<DAL.Model.Message> Messages
        {
            get 
            {
                return MessagesRepository.GetInbox(Group.RowKey);
            }
        }

        public string ID
        {
            get 
            {
                return Group.ID;
            }
        }
 
        public List<Phrase> GreetingsBoard
        {
            get
            {
                return PhrasesRepository.GetPhrasesByUser(Group.RowKey);
            }
        }

        public List<Event> NextEvents
        {
            get
            {
                return EventsRepository.GetNextGroupEvents(Group.RowKey, 10);
            }
        }

        public List<User> Members
        {
            get
            {
                return GroupsRepository.GetGroupMembers(Group.ID);
            }
        }
        #endregion

        #region Dependencies
        [Dependency]
        public IGroupsRepository GroupsRepository { get; set; }
        [Dependency]
        public IPhrasesRepository PhrasesRepository { get; set; }
        [Dependency]
        public IPostsRepository PostsRepository { get; set; }
        [Dependency]
        public IMessagesRepository MessagesRepository { get; set; }
        [Dependency]
        public IEventsRepository EventsRepository { get; set; }
        [Dependency]
        public IUsersRepository UsersRepository { get; set; }
        #endregion
    }
}
